<?php
	session_start();
	if (!isset($_SESSION['sesi_login']))
		header("Location:../../index.php");

	@chdir("../../");
	define('ABS_URL',str_replace("\\","/",getcwd()));
	require ABS_URL.'/engine/Smarty.class.php';
	require ABS_URL."/functions/class.query.inc.php";
	$smarty = new Smarty();
	require ABS_URL."/dev_con.inc.php";
	require ABS_URL."/functions/func_file.php";
	$queryData = new queryData();
	$queryData->baseConfig();
	require ABS_URL."/functions/func_content.php";
	require ABS_URL."/langs/".BASE_LANGUAGE.'.inc.php';
	require $queryData->get_curr_dir(dirname(__FILE__))."/langs/".BASE_LANGUAGE.'.inc.php';

	$nama_propinsi = trim($_POST['nama_propinsi']);
	$nama_kota = trim($_POST['nama_kota']);

	if (strtolower($_GET['act_ver'])=="hapus") {
		$sql = "DELETE FROM kota WHERE idx='".$_GET['kode']."'";
		$qry = mysql_query($sql);
		
		$_SESSION['sesi_ver'] = "Kota has been deleted";
	} elseif ((empty($nama_propinsi)) || (empty($nama_kota))) {
		$_SESSION['sesi_ver'] = "'Nama propinsi OR Nama Kota' form must be defined";
	} else {
		switch (strtolower($_POST['act_ver'])) {
			case "input" :
				$sql = "INSERT INTO kota VALUES(NULL,'".$nama_propinsi."','".$nama_kota."','')";
				$qry = mysql_query($sql);
												
				$_SESSION['sesi_ver'] = "Kota \"".$nama_kota."\" added";
			break;
			case "edit" :
				$header_c = strip_tags($header_c);
				$header_c = htmlspecialchars($header_c);
				$sql = "UPDATE kota SET id_propinsi='".$nama_propinsi."', nama_kota='".$nama_kota."', keterangan_lain='' WHERE idx='".$_POST['kode']."'";
				$qry = mysql_query($sql);
										
				$_SESSION['sesi_ver'] = "Kota \"".$nama_kota."\" updated";
			break;
			default :
			break;
		}
	}
		
	if (isset($_SESSION['sesi_login'])) {
		header("Location:../../?show=".$_GET['show']."&showview=".$_GET['showview']."&act=lihat&limitdown=0");
	} else {
		header("Location:../../index.php");
	};
?>